package com.inspur.security.cbb3.kms.keymanager.containers.service;

import com.inspur.security.cbb3.kms.keymanager.containers.po.ContainersBean;
import com.inspur.security.cbb3.kms.utils.PageRequestDate;
import javassist.NotFoundException;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.MissingServletRequestParameterException;

/**
 * @author: lijunchang
 * @Description: 密钥容器service
 * @Date: 2020/10/19
 */
public interface ContainersService {

    /**
     * 进行密钥容器分页查询
     * @param pageRequestDate   分页参数
     * @param searchParams      查询条件
     * @return  查询结果集
     */
    Page searchContainers(PageRequestDate pageRequestDate, ContainersBean searchParams);

    /**
     * 进行密钥容器单个查询
     * @param uuid  密钥主键
     * @return  查询结果
     * @throws NotFoundException        未找到
     * @throws MissingServletRequestParameterException  缺少参数异常
     */
    ContainersBean searchContainers(String uuid) throws NotFoundException, MissingServletRequestParameterException;

    /**
     *
     * 密钥容器删除,假删除
     * @param uuid  密钥主键
     * @throws NotFoundException        未找到
     * @throws MissingServletRequestParameterException  缺少参数异常
     */
    void deleteContainer(String uuid) throws NotFoundException, MissingServletRequestParameterException;

    /**
     * 进行容器新增
     * @param name  容器名称
     * @param creatorId 创建人
     * @return  新增容器对象
     */
    ContainersBean saveContainersBean(String name,String creatorId);

    /**
     * 进行前端直接传入容器新增
     * @param containersBean    容器对象
     * @return  操作结果
     * @throws NotFoundException    未找到
     * @throws MissingServletRequestParameterException  请求参数不正确
     */
    ContainersBean addContainers(ContainersBean containersBean) throws NotFoundException, MissingServletRequestParameterException;

    /**
     * 向容器中添加密钥
     * @param uuid  容器uuid
     * @param secretUuid    密钥uuid
     * @throws NotFoundException    未找到
     * @throws MissingServletRequestParameterException  请求参数不正确
     */
    void addSecretsToContainer(String uuid, String secretUuid) throws NotFoundException, MissingServletRequestParameterException;

    /**
     * 删除容器中的密钥
     * @param uuid  容器uuid
     * @param secretUuid    密钥uuid
     * @throws NotFoundException    未找到
     * @throws MissingServletRequestParameterException  请求参数不正确
     */
    void deleteSecretsFromContainer(String uuid, String secretUuid) throws NotFoundException, MissingServletRequestParameterException;
}
